#include <stdio.h>

int sum_of_odd_length_subarrays(int arr[], int len) {
    int sum = 0;
    for (int i = 0; i < len; i++) {
        for (int j = i; j < len; j++) {
            if (j - i + 1 % 2 != 0) {
                sum += arr[j];
            }
        }
    }
    return sum;
}

int main() {
    int arr[] = {1, 2, 3, 4, 5};
    int len = sizeof(arr) / sizeof(arr[0]);
    int result = sum_of_odd_length_subarrays(arr, len);
    printf("所有奇数长度子数组的和为：%d\n", result);
    return 0;
}
